package org.ourguy.mymoviesandshows.managers;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

public class ReminderManager {
	public static void addReminderFor(Intent intent, Context context){
		
		NotificationManager mManager =
				(NotificationManager) context.getSystemService(
						Context.NOTIFICATION_SERVICE); 
		
		Notification notification =
				new Notification(android.R.drawable.stat_notify_error,
						"Tracked title update",
						intent.getLongExtra("airTime", 0));
		
		notification.flags |= Notification.FLAG_AUTO_CANCEL;
		
		PendingIntent pi = PendingIntent.getActivity(context, 
				intent.getIntExtra("episodeId", 0), intent, 0);
		
		notification.setLatestEventInfo(context,
				intent.getStringExtra("seriesTitle"),
				"New episode: " + intent.getStringExtra("episodeTitle"), pi);
		
		mManager.notify(intent.getIntExtra("episodeId", 0), notification);  
	}
	
	public static void removeAllReminders(Context context){
		NotificationManager mManager =
				(NotificationManager) context.getSystemService(
						Context.NOTIFICATION_SERVICE);
						
		mManager.cancelAll();
	}
}
